#!/bin/tcsh
#
#  This script runs NWChem on mnemosyne
#
module load mpich
module load nwchem/6.5
#
setenv NWCHEM_PROCS 8
setenv NWCHEM_MEMORY "1200 mb"
setenv NWCHEM_SCRATCH /home/mark/nwchem/scratch
#
set procid=`echo $$`
setenv JOBNAME `ps -p $procid | grep $procid | awk '{print $4}'`
setenv NWCHEM_ROOT `echo $JOBNAME | awk -F_ '{print $1}'`
setenv NWCHEM_SUFFIX `echo $JOBNAME | awk -F_ '{print $2}'`
mkdir $NWCHEM_SCRATCH/$procid
#
# Build the input file
#
cat << finis > $JOBNAME.nw
title "Diamond 3.7 A ball (six fixed atoms)" 

start  $NWCHEM_ROOT
permanent_dir $cwd
scratch_dir $NWCHEM_SCRATCH/$procid
memory $NWCHEM_MEMORY
ecce_print $JOBNAME.ecce

charge 0

geometry units angstroms noautosym noautoz
   C    0.00000    1.78340    1.78340
   C   -0.89170    0.89170    2.67509
   C    1.78340    1.78340    0.00000
   C    0.89170    0.89170    0.89170
   C    2.67509    0.89170   -0.89170
   C    0.00000    0.00000    0.00000
   C    0.00000    0.00000    3.56679
   C    3.56679    0.00000    0.00000
   C   -1.78340    0.00000    1.78340
   C    1.78340    0.00000   -1.78340
   C    1.78340    0.00000    1.78340
   C   -0.89170    2.67509    0.89170
   C    0.89170    2.67509   -0.89170
   C   -0.89170   -0.89170    0.89170
   C    0.89170   -0.89170   -0.89170
   C    0.00000   -1.78340   -1.78340
   C    0.00000   -1.78340    1.78340
   C   -1.78340   -1.78340    0.00000
   C    1.78340   -1.78340    0.00000
   C   -0.89170    0.89170   -0.89170
   C    0.89170    0.89170   -2.67509
   C    0.00000    3.56679    0.00000
   C   -1.78340    1.78340    0.00000
   C   -2.67509    0.89170    0.89170
   C    0.00000    1.78340   -1.78340
   C   -1.78340    0.00000   -1.78340
   C   -3.56679    0.00000    0.00000
   C    0.00000    0.00000   -3.56679
   C    0.89170   -0.89170    2.67509
   C    2.67509   -0.89170    0.89170
   C    0.89170   -2.67509    0.89170
   C    0.00000   -3.56679    0.00000
end

nwpw
  simulation_cell
    boundary_conditions aperiodic
    SC 20.0
  end
  cutoff 10.0
  lmbfgs
  ewald_rcut 3.0
  ewald_ncut 8  
  xc pbe96
  monkhorst-pack 3 3 3
end

#  fix atom 16 18 26 27 28 32
set geometry:actlist 1:15 17 19:25 29:31

driver 
  clear 
  maxiter 30
end

task pspw optimize ignore 
finis
#
#   Run the job
#
mpirun -np $NWCHEM_PROCS nwchem $JOBNAME.nw >& $JOBNAME.nwo
#
#   Clean up scratch directory
rm -rf $NWCHEM_SCRATCH/$procid
